package cn.zl.rtsp.response.core;

import cn.zl.rtsp.response.RTSPResponse;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.DefaultHttpRequest;

/**
 * 处理describe方法，请求服务器rtsp sdp信息
 */
public class DescribeRTSPResponse extends RTSPResponse {

    public DescribeRTSPResponse(ChannelHandlerContext context, DefaultHttpRequest request) {
        super(context, request);
    }

    @Override
    protected void write(StringBuilder builder) {
        StringBuilder sdp = new StringBuilder();
        sdp.append("v=0").append(R_N);
        sdp.append("o=- ").append(session.getId()).append(" 1 in IP4 192.168.0.100").append(R_N);
        sdp.append("t=0 0").append(R_N);
        sdp.append("a=contol:*").append(R_N);
        sdp.append("m=video 0 RTP/AVP 96").append(R_N);
        sdp.append("a=rtpmap:96 H264/90000").append(R_N);
        sdp.append("a=framerate:25").append(R_N);
        sdp.append("a=control:track0").append(R_N);

        builder.append("Content-length: ").append(sdp.length()).append(R_N);
        builder.append("Content-type: application/sdp").append(R_N).append(R_N);

        builder.append(sdp);
        builder.append(R_N);
    }
}
